package sortAlgorithm;

import java.util.Random;

import static sortAlgorithm.ShellSort.printArray;

public class BubbleSort {
    public static void main(String[] args) {
        Random random = new Random();
        int n = 10;
        int[] a = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = random.nextInt(20);
        }
        printArray(a);
        bubbleSort(a);
        printArray(a);
    }

    public static void bubbleSort(int[] array) {
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
    }
}
